<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>注册会员</title>

</head>
        <!-- CSS -->
<link rel="stylesheet" href="__PUBLIC__/assets/css/reset.css">
<link rel="stylesheet" href="__PUBLIC__/assets/css/supersized.css">
<link rel="stylesheet" href="__PUBLIC__/assets/css/style.css">
<link rel="stylesheet" href="__PUBLIC__/layer/skin/layer.css">
        <!-- Javascript -->
<script type="text/javascript" src="__PUBLIC__/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="__PUBLIC__/assets/js/supersized.3.2.7.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/assets/js/supersized-init.js"></script>
<script type="text/javascript" src="__PUBLIC__/assets/js/scripts.js"></script>
<script type="text/javascript" src="__PUBLIC__/layer/layer.js"></script>

<body>
<div id="lg" style="display:block">
<div class="page-container">
            <h1>登录</h1>
            	<div id="form"> 
                <input type="text" name="username"  placeholder="用户名/手机号/邮箱" autocomplete="off">
                <input type="password" name="password"  placeholder="密码" autocomplete="off">
                <input type="text" name="verify"  id="verify" placeholder="验证码" autocomplete="off">
                <a href="#"><img src="__APP__/Home/Common/verify/" style="margin-bottom:-15px;" title="点击刷新验证码" onclick="this.src='__APP__/Home/Common/verify/' + Math.random();" ></a>
                <button type="submit" id="login" style="font-size:18px">登录</button><br><br>
                <a href="#" style="color:green" class='lg'>没有账号？</a>
                <a href="{:U('index/index')}" style="color:green">返回首页</a>
                <div class="error"><span>+</span></div>
                </div>
            <div class="connect">
                <p>合作账号登录:</p>
                <p>
                    <a class="facebook" href="#"></a>
                    <a class="twitter" href="#"></a>
                </p>
            </div>
        </div>
</div>

<div id="rg" style="display:none">
<div class="page-container">
            <h1>注册账号</h1>
            	<div id="form"> 
                <input type="text" name="rusername"  placeholder="手机号" autocomplete="off">
                <input type="password" name="rpassword"  placeholder="密码" autocomplete="off">
                <input type="text" name="rverify"  id="verify" placeholder="验证码" autocomplete="off">
                <button type="submit" id="sendsms" style="font-size:15px;width:35%;background:green;border:1px solid green;">发送验证码</button>
                <button type="submit" id="add" style="font-size:18px">注册</button><br><br>
                <a href="#" style="color:green" class='rg'>已有账号？</a>
                <a href="{:U('index/index')}" style="color:green">返回首页</a>
                <div class="error"><span>+</span></div>
                </div>
            <div class="connect">
                <p>合作账号登录:</p>
                <p>
                    <a class="facebook" href="#"></a>
                    <a class="twitter" href="#"></a>
                </p>
            </div>
        </div>
</div>
</div>		


<script type="text/javascript">
	$(function(){
		//切换登录
		$(".lg").click(function(){
			$("#lg").css("display","none");
			$("#rg").css("display","block");
		})
		//切换注册
		$(".rg").click(function(){
			$("#lg").css("display","block");
			$("#rg").css("display","none");
		})

		//短信注册
		$("#sendsms").click(function(){
			tel = $("input[name='rusername']").val();
			reg = /^1[3|5|7|8][0-9]\d{8}$/;
			if(!reg.test(tel)){
				layer.alert("<span style='color:#000'>请输入正确的号码！</span>",{icon: 5});
				return false;
			}

			$.post("{:U('Common/send_sms')}",{tel:tel},function(data){
				 if(data.info == 1){

						var time = 120;
						function timeCountDown(){
							if(time==0){
							clearInterval(timer);
							document.getElementById("sendsms").disabled="";
							$('#sendsms').css({"background":"green","border":"1px solid green"});
							$('#sendsms').html("发送验证码");
							return true;
						}

						$('#sendsms').css({"background":"#aaa","border":"1px solid #aaa"});
						document.getElementById("sendsms").disabled=true;
						$('#sendsms').html(time+"S后再次发送");

						time--;
						return false;
						}
					
						
						timeCountDown();
						
						var timer = setInterval(timeCountDown,1000);


				 }else{
				 	layer.alert("<span style='color:#000'>"+data.info+"</span>", {icon: 5})
				 }
			})
		})

		//注册验证
		$("#add").click(function(){
			username = $("input[name='rusername']").val();
			password = $("input[name='rpassword']").val();
			verify = $("input[name='rverify']").val();
			$.post("{:U('user/add')}",{username:username,password:password,verify:verify},function(data){
				 if(data.info == 1){
				 	window.location.href="{:U('index/index')}";
				 }else{
				 	layer.alert("<span style='color:#000'>"+data.info+"</span>", {icon: 5})
				 }
			})
		})

		//登录验证
		$("#login").click(function(){
			username = $("input[name='username']").val();
			password = $("input[name='password']").val();
			verify = $("input[name='verify']").val();
			$.post("{:U('user/login')}",{username:username,password:password,verify:verify},function(data){
				if(data.info == 1){
					window.location.href="{:U('index/index')}";
				}else{
				 	layer.alert("<span style='color:#000'>"+data.info+"</span>", {icon: 5})
				}
			})
		})

	})
</script>
</body>
</html>